package com.lzz.dao;

import com.lzz.entity.Student;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Component 该注解是解决IDEA mapper注入时显示could not autowrite,no beans type of 'studentDao' fount。
 * 不加这个注解也能正常运行，但是报个红很不舒服，就加上了
 *
 * CacheConfig(cacheNames = "student") cacheNames必须写
 * @author zhenzhen
 * @date 2018-12-18 下午11:13
 */
@Mapper
@Component(value = "studentDao")
@CacheConfig(cacheNames = "student")
public interface StudentDao {
    int add(Student student);

    /**
     * 获取指定id的学生
     * @param id
     * @return
     */
    @Cacheable(key = "#p0")
    Student getStudent(Integer id);

    /**
     * 查询所有数据
     * @return
     */
    List<Student> getAll();
}
